<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="author" content="">
    <title>chy</title>
    <style>
       div{
           width: 1383px;
           margin: 80px auto;
           font-size: 80px;
       }
       span{
           font-size: 80px;
       }
    </style>
</head>

<body>
    <div>距离5月7日还有：<span></span>天<span></span>小时<span></span>分<span></span>秒</div>
    <script>
        var spans = document.querySelectorAll('span');

        setInterval(function () {
            var now = new Date();
            var end = new Date(2021, 5, 7, 0, 0, 0);
            var num = end.getTime() - now.getTime();
            var day = parseInt(num / (24 * 60 * 60 * 1000)-30);
            num = num % (24 * 60 * 60 * 1000);
            var hour = parseInt(num / (60 * 60 * 1000));
            num = num % (60 * 60 * 1000);
            var min = parseInt(num / (60 * 1000));
            num = num % (60 * 1000);
            var sec = parseInt(num / 1000);
            spans[0].innerHTML = day;
            spans[1].innerHTML = hour;
            spans[2].innerHTML = min;
            spans[3].innerHTML = sec;
        }, 1000)

    </script>
</body>

</html>